package com.shijie.controller.common;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shijie.core.Result;
import com.shijie.core.ResultGenerator;
import com.shijie.domain.entity.Regions;
import com.shijie.service.RegionsService;

/*
 *  @author: smart boy
 *  @date: 2018-03-10
 */
@Controller
@RequestMapping("/common/regions")
public class RegionsController {

	@Autowired
	private RegionsService regionsService;

	
	/** 省份 */
	@RequestMapping(value="/provinces")
	@ResponseBody
	public List<Regions> province() {
		return regionsService.getAllProvince();
	}
	
	/** 市区 */
	@RequestMapping(value="/cities/{provinceId}")
	@ResponseBody
	public List<Regions> cities(@PathVariable("provinceId") String provinceId) {
		return regionsService.getCitiesByProvinceId(provinceId);
	}
	
	/** 区域 */
	@RequestMapping(value="/areas/{cityId}")
	@ResponseBody
	public List<Regions> areas(@PathVariable("cityId") String cityId) {
		return regionsService.getAreasByCityId(cityId);
	}
	
}

